package com.jckl.foodathon.common.util;

import java.lang.reflect.Type;
import java.util.Date;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;

public class GsonUtil {
	
	public static Gson deserializeGson(){
    	GsonBuilder builder = new GsonBuilder();
    	builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() { 
    		   public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    		      return new Date(json.getAsJsonPrimitive().getAsLong()); 
    		   } 
    		});
    	Gson gson = builder.create();
    	return gson;
	}

}
